home *** CD-ROM | disk | FTP | other *** search
/ ...taking it to the Macs! / ...taking it to the Macs!.iso / Extras / ActiveX Mac SDK / ActiveX SDK / Sample Controls / PopupWindow / CPopupWindowControl.h < prev    next >
Encoding:
Text File  |  1996-12-20  |  5.1 KB  |  160 lines  |  [TEXT/CWIE]

  1. ///////////////////////////////////////////////////////////////////////////////
  2. //
  3. //    CPopupWindowControl.h
  4. //
  5. //        The PopupWindow control is designed to bring up a window whenever the 
  6. //        mouse moves over the label designated as its source. Inside the window, 
  7. //        PopupWindow renders the contents of the specified URL
  8. //
  9. //        In this demonstration version, a mouse click in the specified label is 
  10. //        required, pending implementatin of a mouseOver event.
  11. //
  12. //        In this demonstration version, only pict files are rendered, pending 
  13. //        implementation of MSHTML to render the contents of URL's.
  14. //
  15. //        In this demonstration version, the image is rendered in a rect within 
  16. //        the browser window rather than in a separate window.
  17. //
  18.  
  19. #ifndef __CPOPUPWINDOWCONTROL__
  20. #define __CPOPUPWINDOWCONTROL__
  21.  
  22. #include "BDInterfaces.h"
  23. #include "CBaseBindStatusCallback.h"
  24. #include "CErrorControl.h"
  25.  
  26. ///////////////////////////////////////////////////////////////////////////////
  27. //
  28. //    Constants
  29. //
  30.  
  31. const short cNumConnections = 1;    //    This control only has one connection point
  32. const short cMaxNumSourceControls = 50;    //    an arbitrary limit. We could make this dynamic. 
  33. const char cSourceObjectStr[] = "sourceobject";    //    HTML parameter name
  34. const unsigned long cPictHeaderSize = 512;    //    Pict file header size
  35. const char cPopupControlName[] = "Popup";    //    Default name for the control.
  36. const char cEmptyCString[] = "";
  37.  
  38. ///////////////////////////////////////////////////////////////////////////////
  39. //
  40. //    Data Structures
  41. //
  42.  
  43. typedef struct
  44. {
  45.     Rect      PicRect;
  46.     PicHandle Pic;
  47. }
  48. pictInfo;
  49.  
  50. ///////////////////////////////////////////////////////////////////////////////
  51.  
  52. class CBaseBindStatusCallback;
  53. class CPopupWindowError;
  54.  
  55. ///////////////////////////////////////////////////////////////////////////////
  56. //
  57. // class declaration
  58. //
  59.  
  60. class CPopupWindowControl : 
  61.     public CBaseControl,
  62.     public CBaseBindStatusCallback,
  63.     public IDoMenuEvents,
  64.     public CErrorControl
  65. {
  66. public:
  67.     
  68.     // *** CPopupWindowControl methods ***
  69.     CPopupWindowControl ();
  70.     ~CPopupWindowControl ();
  71.  
  72.     //  *** IUnknown methods ***
  73.     STDMETHOD (QueryInterface) ( REFIID RefID, void** Obj );
  74.     STDMETHOD_ (ULONG, AddRef) ( THIS ) { return (CBaseControl::AddRef ()); }
  75.     STDMETHOD_ (ULONG, Release) ( THIS ) { return (CBaseControl::Release ()); }
  76.  
  77.     // *** IObjectWithSite methods ***
  78.     STDMETHOD (SetSite) ( THIS_ IUnknown* inUnkSite );
  79.  
  80.     // *** IControl methods ***
  81.     STDMETHOD (Draw) ( DrawContext* Context );
  82.     STDMETHOD (DoIdle) ( THIS_ Uint32 IdleRefCon );
  83.     
  84.     //  *** IPersistPropertyBag methods ***
  85.     STDMETHOD (Load) ( IPropertyBag* PropBag, IErrorLog* ErrorLog );
  86.  
  87.     //  *** CBaseBindStatusCallback methods ***
  88.     STDMETHOD (OnStopBinding) ( ErrorCode Result, const Char8* Error );
  89.     STDMETHOD (OnDataAvailable) ( Uint32 BSCF, 
  90.                                   Uint32 Size, 
  91.                                   FORMATETC* FormatEtc, 
  92.                                   STGMEDIUM* StgMedium );
  93.  
  94.     // **** IDoMenuEvents methods
  95.     STDMETHOD (Popup) ( THIS_ IUnknown* Source, PlatformEvent* Event );
  96.     
  97.     //    These are IDoMenuEvents methods which PopupWindow doesn't need.
  98.     STDMETHOD (Clear) ( THIS_ IUnknown* /* Source */, PlatformEvent* /* Event */ )
  99.         { return ResultFromScode ( E_NOTIMPL ); }
  100.     STDMETHOD (RemoveItem) ( THIS_ IUnknown* /* Source */, 
  101.                              PlatformEvent* /* Event */, 
  102.                              const CMenuItem & /* Item */ )
  103.         { return ResultFromScode ( E_NOTIMPL ); }
  104.     STDMETHOD (AddItem) ( THIS_ IUnknown* /* Source */, 
  105.                           PlatformEvent* /* Event */, 
  106.                           const CMenuItem & /* Item */ )
  107.         { return ResultFromScode ( E_NOTIMPL ); }
  108.     
  109. friend CPopupWindowError;
  110.  
  111. protected:
  112.     Boolean            SetName ( const char * theName );
  113.     Boolean            SetSourceName ( const char * theName );
  114.     Boolean            AddDesiredSourceName ( const char * theName );
  115.     Boolean            AddSource ( const char * sourceName, Boolean * alreadyFoundIt );
  116.     Boolean            IsSource ( IUnknown * unk );
  117.     Boolean            IsSource ( const char * sourceName );
  118.     void             DrawPict ( GrafPtr pGrafDraw, 
  119.                                Rect* lprect, 
  120.                                PicHandle Pic, 
  121.                                Rect* PictRect );
  122.     Boolean            AllocatePictBuffer ( void );
  123.     Boolean            ReadPictHeader ( STGMEDIUM* StgMedium );
  124.     Boolean            ReadPictData ( STGMEDIUM* StgMedium );
  125.     
  126. protected:
  127.     char *            mSourceName;
  128.     char *            mDesiredSourceNames[cMaxNumSourceControls];
  129.         //    the names of the specific controls that we want to get messages from
  130.     char *            mFoundSourceNames[cMaxNumSourceControls];
  131.         //    the names of the specific controls that we've connected to
  132.     long            mNumDesiredSources;
  133.     long            mNumFoundSources;
  134.     Boolean            mIsIdling;    //    True if we're getting idle messages
  135. #ifdef _DEBUG
  136.     char            mThisName[256];
  137. #endif
  138.     Int32            mPictBytesRemaining;
  139.     Int32            mPictBytesSoFar;
  140.     GrafPtr            mDrawPort;
  141.     Uchar8            mDataURL[MAX_URL_STRING];
  142.     LPBINDHOST         mBindSiteP;
  143.     pictInfo**        mPict;
  144.     Boolean            mPictIsLoaded;
  145.     Boolean            mPendingDraw;
  146.     unsigned long    mPopupWidth;
  147.     unsigned long    mPopupHeight;
  148.     Boolean            mFatalError;    //    After failure, so I don't respond.
  149.  
  150. private:
  151.     DWORD            mCookie;
  152.         //    NOTE: if we ever actually use this for something, we need a 
  153.         //    list of them, since we allow connections to more than
  154.         //    one specific sources.
  155.     Boolean            mConnectingComplete;
  156. };
  157.  
  158.  
  159. #endif // __CPOPUPWINDOWCONTROL__
  160.